/***************************************************************************\
 * Copyright (C) by Keio University
 * OpenNIDepthInputStream.hpp created in 10 2011.
 * Mail : fdesorbi@hvrl.ics.keio.ac.jp
 *
 * OpenNIDepthInputStream.hpp is part of the HVRL Engine Project.
 *
 * The HVRL Engine Project is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * The HVRL Engine Project is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 \***************************************************************************/

#ifndef VIDEO__OPENNI_DEPTH_INPUT_STREAM_HPP__
#define VIDEO__OPENNI_DEPTH_INPUT_STREAM_HPP__

#include "hvrl/video/DepthInputStream.hpp"

#include <XnCppWrapper.h>

#if (XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM)
	#define UNIX
	#define GLX_GLXEXT_LEGACY
#endif

#if (XN_PLATFORM == XN_PLATFORM_MACOSX)
	#define MACOS
#endif

#include <XnLog.h>
#include <XnTypes.h>

//#ifdef WIN32
//#include <Win32/XnOSWin32.h>
//#else
//#include <ni/XnOS.h>
//#include <ni/XnCppWrapper.h>
//#include <ni/XnLog.h>
//#endif


namespace hvrl
{

  class OpenNIDepthInputStream
  {

  private:

  public:

    OpenNIDepthInputStream(void);

    bool init(void);

    virtual
    ~OpenNIDepthInputStream(void);

    virtual const short unsigned int *
    getDepth(void) const;

    virtual const unsigned char*
    getColor(void) const;

    virtual const short unsigned int *
    getIR(void) const;

    virtual void
    update(void);

    virtual cv::Size
    getDepthSize(void) const
    {
      return this->depth_size;
    }

    virtual cv::Size
    getColorSize(void) const
    {
      return this->depth_size;
    }

    virtual cv::Size
    getIRSize(void) const
    {
      return this->ir_size;
    }

    virtual const float&
    getBackProjection(void) const
    {
      return this->bpcoeff;
    }

    virtual double
    getParameter(const int&);

    virtual bool
    setParameter(const int&, const double& value);

  public:
    xn::DepthGenerator depth;
    xn::DepthMetaData depth_metadata;
    xn::IRGenerator ir;
    xn::IRMetaData ir_metadata;
    xn::ImageGenerator color;
    xn::ImageMetaData color_metadata;
    xn::Context context;
    cv::Size depth_size;
    cv::Size color_size;
    cv::Size ir_size;
    xn::Device device;
    // cv::Mat color_map;
    // cv::Mat depth_map;
    //float * ddd_map;
    float bpcoeff;
  };

}

#endif
